﻿using System;
using System.Collections.Generic;
using System.Linq;
using Sustainalytics.Synchronization.Validation.ValidationRules.Common;

namespace Sustainalytics.Synchronization.Validation.ValidationRules.Comprehensive
{
    public abstract class ComprehensiveRule<T> : Rule<T>
    {
    }


    public abstract class ComprehensivePercentChangeBetween<T> : ComprehensiveRule<T>
    {
        private readonly IComparable to;
        private readonly IComparable from;

        protected ComprehensivePercentChangeBetween(IComparable from, IComparable to = null)
        {
            this.from = from;
            this.to = to;
        }

        protected bool Validator(T validatedEntity, T referenceEntity)
        {
            var modelValue = (IComparable)GetValue(validatedEntity);
            var referenceValue = (IComparable)GetValue(referenceEntity);

            return RulesExtensions.Validator(modelValue, referenceValue, from, to);
        }
    }
}
